package com.ebupt.migu.music.media.enums;

import lombok.Getter;

import java.util.ArrayList;
import java.util.List;

@Getter
public enum OperatorEnum {
    FROPERTY_ENUM_1(1,"01", "不清楚运营商类型"),
    FROPERTY_ENUM_2(1,"02", "中国移动"),
    FROPERTY_ENUM_3(1,"03", "中国联通"),
    FROPERTY_ENUM_4(1,"04", "中国电信"),
    FROPERTY_ENUM_5(2,"0", "未登录"),
    FROPERTY_ENUM_6(2,"1", "登录");

    final Integer type;
    final String code;
    final String name;

    OperatorEnum(Integer type, String code, String name) {
        this.type = type;
        this.code = code;
        this.name = name;
    }

    public static List<OperatorEnum> getByType(Integer type) {
        List<OperatorEnum> list=new ArrayList<>();
        for (OperatorEnum v : values()) {
            if (v.getType()==type) {
                list.add(v) ;
            }
        }
        return list;
    }

    public static String getCodeByName(int code) {
        for (OperatorEnum v : values()) {
            if (v.getCode().equals(code) ) {
                return v.getName();
            }
        }
        return null;
    }

    public static String getNameByCode(String name) {
        for (OperatorEnum v : values()) {
            if (v.getName().equals(name)) {
                return v.getCode();
            }
        }
        return null;
    }
}
